{% extends "base.html" %}

{% block title %}作品管理 - 校园摄影投票系统{% endblock %}

{% block content %}
    <div class="container-fluid">
        <h1 class="mt-4">作品管理</h1>
        
        <div class="card shadow mb-4 mt-4">
            <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-primary">待审作品 ({{ pending_photos|length }})</h6>
            </div>
            <div class="card-body">
                {% if pending_photos %}
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>标题</th>
                                <th>作者</th>
                                <th>上传时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for photo in pending_photos %}
                            <tr>
                                <td>{{ photo.id }}</td>
                                <td>{{ photo.title }}</td>
                                <td>{{ photo.author.username }}</td>
                                <td>{{ photo.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                                <td>
                                    <a href="{{ url_for('admin.approve_photo', photo_id=photo.id) }}" 
                                       class="btn btn-sm btn-success">批准</a>
                                    <a href="{{ url_for('admin.reject_photo', photo_id=photo.id) }}" 
                                       class="btn btn-sm btn-danger">拒绝</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% else %}
                <div class="alert alert-info">没有待审作品</div>
                {% endif %}
            </div>
        </div>
        
        <div class="card shadow mb-4">
            <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-primary">已批准作品 ({{ approved_photos|length }})</h6>
            </div>
            <div class="card-body">
                {% if approved_photos %}
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>标题</th>
                                <th>作者</th>
                                <th>票数</th>
                                <th>上传时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for photo in approved_photos %}
                            <tr>
                                <td>{{ photo.id }}</td>
                                <td>{{ photo.title }}</td>
                                <td>{{ photo.author.username }}</td>
                                <td>{{ photo.vote_count }}</td>
                                <td>{{ photo.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                                <td>
                                    <a href="{{ url_for('main.photo_detail', photo_id=photo.id) }}" 
                                       class="btn btn-sm btn-info">查看</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% else %}
                <div class="alert alert-info">没有已批准作品</div>
                {% endif %}
            </div>
        </div>
    </div>
{% endblock %}